(function(mui,$){
	var all = {
		init : function(){
			var year = new Date().getFullYear();
			var month = new Date().getMonth()+1;
			var day = new Date().getDate();
			if(day < 10){
				day = '0' + day;
			}
			var start = year + '-' + month + '-01';
			var end = year + '-' + month + '-' + day;
			var startVal = $("#start").val();
			var endVal = $("#end").val();
			if(startVal == '' || startVal == null){
				$("#start").val(start);
			}
			if(endVal == '' || endVal == null){
				$("#end").val(end);
			}
			var items = ['start','end'];
			for(var i = 0; i < items.length; i++){
				this.selectInit(items[i],year);
			}
			document.getElementById('query').addEventListener('tap',all.query);
		},
		selectInit : function(id,year){
			var pickerButton = document.getElementById(id);
			var options = {
				type : 'date',
				beginYear : year-2,
				endYear : year+2
			};
			if(pickerButton.value != ''){
				options.value = pickerButton.value;
			}
			var picker = new mui.DtPicker(options);
			pickerButton.addEventListener('tap', function() {
				var self = pickerButton;
				picker.show(function(items){
					self.value = items.text;
				});
			}, false);
		},
		query : function(){
			var start_time = $("#start").val();
			var end_time = $("#end").val();
			$("input[name='start_time']").val(start_time+' 00:00:00');
			$("input[name='end_time']").val(end_time+' 23:59:59');
			$("#queryForm").submit();
		}
	};
	window.select = all;
})(mui,$);
